package com.fenghongzhang.module_main.model

import com.fenghongzhang.lib_core.utils.GSON
import okhttp3.RequestBody
import okhttp3.MediaType.Companion.toMediaType
import java.io.File

open class BaseBody {
    open fun toJson(): String {
        return GSON.toJson(this)
    }

    fun toRequestBody(): RequestBody {
        return RequestBody.create("application/json".toMediaType(), this.toJson())
    }
}

class ApplyClubBody : BaseBody() {
    var clubId: String? = ""
    var clubName: String? = ""
    var memberId: String? = ""
    var clubMemberId: String? = ""

    // 姓名
    var nickName = ""

    // 性别：0-女，1男，2未知
    var gender = 0

    // 年龄
    var age = 0

    // 有无活动组织经验
    var ifOrg = 0

    // 驾龄
    var driving = 0f

    // 摩托车型号
    var modelId = ""
    var model: String? = ""

    // 骑行宣言100个字
    var declaration = ""

    // 行驶证
    var vehicleLicense = ""

    // 驾驶证
    var driverLicense = ""

    fun requiredAgeBigThanDriving(): Boolean {
        if (driving > age)
            return false
        return true
    }

    fun requiredGenderName(): String {
        return when (gender) {
            0 -> "女"
            1 -> "男"
            else -> "--"
        }
    }

    fun requiredAge(): String {
        return age.toString()
    }

    fun requiredDriving(): String {
        return "${driving}年"
    }
}

class SignUpActBody : BaseBody() {
    var name: String? = null
    var gender: Int? = null
    var phone: String? = null
    var smsCode: String? = null
}

/** 发布动态对象 */
class PublishTimelineBody : BaseBody() {
    var activityId: String = ""
    var clubId: String = ""
    var memberId: String = ""
    var content: String = ""
    var imgs: String = ""

    // location=地点的title
    var location: String = ""
    var lat: Double = 0.0
    var lon: Double = 0.0
}

open class BasePublishCommentBody : BaseBody() {
    // 被回复人ID
    var beReplyId: String = ""

    // 回复内容
    var content: String = ""

    // 顶级评论ID
    var firstCommentId: String = ""

    // 父级ID
    var parentId: String = ""
}

/** 发布评论 */
class PublishCommentBody : BasePublishCommentBody() {
    // 动态ID
    var dynamicId: String = ""

}

class PublishInfoCommentBody : BasePublishCommentBody() {
    // 	资讯Id
    var informationId: String = ""

    // 	资讯评论Id
    var informationCommentId: String = ""
}

class RatingBody : BaseBody() {
    var clubId: String = ""
    var content: String = ""
    var score: Float = 0f
    var scoreId: String = ""
}

class RatingValidationBody(var clubId: String = "") : BaseBody() {
    var codeDescribe: String = ""
}

class ClubValidationBody(var clubId: String, var type: Int = 2) : BaseBody()

// 会员发起退款
open class ApplyRefundBody(
    var orderId: String = "",
    var refundReason: String = ""
) : BaseBody()

// 管理员审核退款
class AuditRefundBody(
    var orderId: String = "",
    var refundReason: String = "",
    // 审核状态(1:已通过 2:已拒绝)
    var auditState: Int = 0,
    var refuseReason: String = ""
) : BaseBody() {
    companion object {
        const val AUDIT_AGREE = 1
        const val AUDIT_REJECT = 2
    }
}

class CommentLikeBody(
    var commentId: String = "",
    // 有地方用dynamicId,后端没统一
    var dynamicId: String = "",
    // 有地方用thirdId,后端没统一
    var thirdId: String = "",
    var ifLike: Int = 1,
    // CollectionTypeEnum
    // 类型(1:帖子 2:文章 3:指南 4:话题 5:动态: 6:资讯 7:路线 8:组队 9:商品)
    var type: Int = 0
) : BaseBody()

class CommentValidationBody(
    var beReplyId: String = "",
    var dynamicId: String = "",
    var parentId: String = ""
) : BaseBody()

class StopClubActivityBody(
    var activityId: String = "",
    var auditContent: String = "",
) : BaseBody()

class CreateActBody : BaseBody() {
    // 	活动封面图
    var activityImg = ""

    // 	详情封面图
    var detailsImg = ""

    // 活动名称
    var activityName = ""

    // 	俱乐部Id
    var clubId = ""

    // 	是否付费(1:是 0:否)
    var ifPay = 0

    // 	费用
    var amount = 0f

    // 是否需购买意外险(1:是 0:否)
    var ifAccident = 0

    // 活动ID
    var activityId = ""

    // 活动详情
    var activityDetails = ""

    // 	活动开始时间
    var activityStartTime = ""

    // 	活动结束时间
    var activityEndTime = ""

    // 报名开始时间
    var signUpStartTime = ""

    // 报名结束时间
    var signUpEndTime = ""

    // 活动路线
  //  var routes: List<RouteItem>? = null
}

class ClubImageItem(
    var url: String? = null,
    var file: File? = null,
    var index: Int = 0,
) {
    fun ifFile() = file != null
}

class CreateClubBody : BaseBody() {
    // 俱乐部ID
    var clubId: String? = null

    // 渠道1后台2用户
    var channel: String? = ""

    // 详细地址
    var address: String? = null

    // 市
    var city: String? = null

    // 俱乐部详情
    var clubDetails: String? = null

    // 俱乐部名称
    var clubName: String? = null

    // 	俱乐部头像
    var headImg: String? = null

    // 	负责人姓名
    var headName: String? = null

    // 纬度
    var lat: Double? = null

    // 经度
    var lon: Double? = null

    // 	成立时间
    var setTime: String? = null

    // 	场地大小
    var siteSize: String? = null

    // 俱乐部头轮播图多张,号隔开
    var turnImg: String? = null
}